package com.botann.projects.model;

import javax.persistence.*;
import java.util.Date;

/**
 * server-simple
 * UserSecret
 * Created by 刘山国 on 2019/10/15.
 * Copyright (c) 2017 伯坦科技. All rights reserved
 */
@Entity
@Table(name = "user_secret", schema = "db_server_simple", catalog = "")
public class UserSecret {
    private long id;
    private int userId;
    private String password;
    private int type;
    private String secretKey;
    private Date expireTime;

    @Id
    @Column(name = "id", nullable = false)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "user_id", nullable = false)
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "password", nullable = false, length = 128)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "type", nullable = false)
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Basic
    @Column(name = "secret_key", nullable = false, length = 64)
    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    @Basic
    @Column(name = "expire_time", nullable = false)
    public Date getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(Date expireTime) {
        this.expireTime = expireTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserSecret that = (UserSecret) o;

        if (id != that.id) return false;
        if (userId != that.userId) return false;
        if (type != that.type) return false;
        if (password != null ? !password.equals(that.password) : that.password != null) return false;
        if (secretKey != null ? !secretKey.equals(that.secretKey) : that.secretKey != null) return false;
        if (expireTime != null ? !expireTime.equals(that.expireTime) : that.expireTime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + userId;
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + type;
        result = 31 * result + (secretKey != null ? secretKey.hashCode() : 0);
        result = 31 * result + (expireTime != null ? expireTime.hashCode() : 0);
        return result;
    }
}
